Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIMD-0189: SBPF stricter ELF headers #189

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Lichtso
Copy link
Contributor

@Lichtso Lichtso commented Oct 23, 2024

No description provided.

@@ -0,0 +1,131 @@
---
simd: '0187'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update the SIMD number (and PR title) to match the PR number, per https://github.com/solana-foundation/solana-improvement-documents/blob/main/proposals/0001-simd-process.md#draft

@Lichtso Lichtso changed the title SIMD-0187: SBPF stricter ELF headers SIMD-0189: SBPF stricter ELF headers Oct 31, 2024
@Lichtso Lichtso force-pushed the sbpf-stricter-elf-headers branch from eb17010 to 51bec42 Compare October 31, 2024 21:38
- `p_memsz` must fit in 32 bits / be less than `1 << 32`
- `p_align` is ignored

If any check fails `ElfParserError::InvalidProgramHeader` must be thrown.
Copy link

@topointon-jump topointon-jump Nov 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mind specifying where in the program lifecycle this will be thrown? (i.e. will these new checks be enforced at deployment time? when loading into the program cache for execution? both?)

What is the plan for currently deployed programs?

Copy link

@topointon-jump topointon-jump Nov 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or is this SIMD associated with an SBPF version?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is associated with a SBPF version (see title), though the specific one is not decided yet.
And these checks will all happen at load time (deployment or feature set change), not at runtime.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we specify in the SIMD where the checks will be performed, and what happens if they fail?

Comment on lines +72 to +73
| stack | PT_GNU_STACK | PF_R, PF_W | 2 << 32 |
| heap | PT_LOAD | PF_R, PF_W | 3 << 32 |

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we allow these headers? These regions are configured independently of the ELF. Do we allow these headers just so that we can reduce LLVM modifications? Just curious.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is so that the memory regions are correctly reflected in the ELF header. This makes it easier for tooling to detect issues (such as overlap in section allocation) and could simplify the validator implementation in the future.

Also, with the upcoming CPI syscall restrictions (necessary for direct mapping) we will limit pointers provided by the user to come from the stack and heap. Thus their layout will be further solidified.


If any check fails `ElfParserError::InvalidProgramHeader` must be thrown.

### Dynamic symbol table
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you choose the dynamic symbol table entry SHT_DYNAMIC and not the symbol table elf entry SHT_SYMTAB?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants